using System;
using System.Collections.Generic;
using System.Text;

using NHibernate;
using NHibernate.Data.Models;
using NHibernate.Data.Base;

namespace NHibernate.Data.Managers
{
    public partial interface IReWineStyleManager : IManagerBase<ReWineStyle, string>
    {
		// Get Methods
		ReWineStyle GetById(System.Int64 style, System.Int64 wine);
    }

    partial class ReWineStyleManager : ManagerBase<ReWineStyle, string>, IReWineStyleManager
    {
		#region Constructors
		
		public ReWineStyleManager() : base()
        {
        }
        public ReWineStyleManager(INHibernateSession session) : base(session)
        {
        }
		
		#endregion
		
        #region Get Methods

		public override ReWineStyle GetById(string id)
		{
			string[] keys = id.Split('^');
			
			if(keys.Length != 2)
				throw new Exception("Invalid Id for ReWineStyleManager.GetById");
			
			return GetById(System.Int64.Parse(keys[0]), System.Int64.Parse(keys[1]));
		}
		public ReWineStyle GetById(System.Int64 style, System.Int64 wine)
		{
			ICriteria criteria = Session.GetISession().CreateCriteria(typeof(ReWineStyle));
			
			criteria.Add(NHibernate.Criterion.Expression.Eq("Style", style));
			criteria.Add(NHibernate.Criterion.Expression.Eq("Wine", wine));
			
			ReWineStyle result = (ReWineStyle)criteria.UniqueResult();

            if (result == null)
                throw new NHibernate.ObjectDeletedException("", null, null);

            return result;
		}
		
		
		#endregion
    }
}